package org.javaboy.validation_demo.controller;

import org.javaboy.validation_demo.model.User;
import org.javaboy.validation_demo.validation.CreateGroup;
import org.javaboy.validation_demo.validation.EditGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @PostMapping("/user")
    public User addUser(@RequestBody @Validated(CreateGroup.class) User user) {
        return user;
    }

    @PutMapping("/user")
    public User updateUser(@RequestBody @Validated(EditGroup.class) User user) {
        return user;
    }
}
